import matplotlib.pyplot as plt
import numpy as np

# plt.errorbar(x, y, yerr=a, xerr=b)
# 函数功能：绘制y轴方向或是x轴方向的误差范围
# x：数据点的水平位置
# y：数据点的垂直位置
# yerr：y轴方向的数据点的误差计算方法
# xerr：x轴方向的数据点的误差计算方法

fig = plt.figure()
y1 = [151.32, 148.54, 138.72, 122.45, 119.12, 122.23, 137.53, 128.02, 124.71]
y2 = [268.75, 255.32, 248.98, 224.31, 204.77, 151.36, 140.23, 130.74, 126.25]
y3 = [298.78, 269.35, 249.71, 240.53, 234.16, 175.31, 152.84, 150.25, 143.42]
y4 = [317.23, 300.09, 289.28, 282.37, 253.43, 220.19, 183.24, 161.47, 149.88]

res = [y1, y2, y3, y4]
res = np.array(res)
res = np.mean(res, axis=0)

x = [0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8]
y = res


# 当uplims参数的值为True时，向上的误差线不显示，向下的误差线加箭头
# 当lolims参数的值为True时，向下的误差线不显示，向上的误差线加箭头
plt.errorbar(x, y1, yerr=res, uplims=True, label='LDC-COR')
plt.errorbar(x, y2, yerr=res, uplims=True, label='LDC-OR')
plt.errorbar(x, y3, yerr=res, uplims=True, label='LDC-ACOR')
plt.errorbar(x, y4, yerr=res, uplims=True, label='LDC-AOR')

plt.legend(loc='lower right')
plt.tight_layout()
plt.show()

